#ifndef _Philosophers_NewGame_h_
#define _Philosophers_NewGame_h_

#include <CtrlLib/CtrlLib.h>

using namespace Upp;
#define LAYOUTFILE <Philosophers/NewGame.lay>
#include <CtrlCore/lay.h>

#include "Person.h"

// New game dialog class
class NewGameDlg: public WithNewGameDialog<TopWindow> {
	typedef NewGameDlg CLASSNAME;
	int *speed; // game speed
	int *maxHung; // starvation threshold
	bool *stopDead; // stop if deadlock
	Array<Person> *list; // editable philosophers list
	int sel; // current philosophers index
	String *logFile; // log file path
	
public:
	// Constants
	static const int minMaxHunger = 0; // min. starvation threshold (off)
	static const int maxMaxHunger = 1000; // max. starvation threshold
	static const int minSpeed = 10; // min. game speed
	static const int maxSpeed = 1000; // max. game speed

	NewGameDlg(); // Constructor

	// Event handling:
	void OnCancel(); // cancel changes
	void OnStart(); // prepare for game start
	void OnAdd(); // adding a philosopher to the list
	void OnRemove(); // removing a philosopher from the list
	void OnApply(); // applies changes
	void OnDiscard(); // discards changes
	void OnSelect(); // updates editor on select
	void OnBrowse(); // log file selection
	
	// Extended methods:
	void Link(int *, int *, bool *, Array<Person> *, String *); // links the dialog with main window via params
};

#endif
